package cn.yuanqiao.web.controller.archive.detection;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.yuanqiao.common.annotation.Log;
import cn.yuanqiao.common.enums.BusinessType;

import cn.yuanqiao.archive.detection.domain.DetailLogs;
import cn.yuanqiao.archive.detection.service.IDetailLogsService;
import cn.yuanqiao.common.web.controller.BaseController;
import cn.yuanqiao.common.core.domain.AjaxResult;
import cn.yuanqiao.common.utils.poi.ExcelUtil;
import cn.yuanqiao.common.web.page.TableDataInfo;

/**
 * 检测详情Controller
 *
 * @author xy
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/archive/detailLogs")
public class DetailLogsController extends BaseController {
    @Autowired
    private IDetailLogsService detailLogsService;

    @Value("${is_zt}")
    private String isZt;

    /**
     * 查询检测详情列表
     */
/*
    @PreAuthorize("@ss.hasPermi('archive:DetailLogs:list')")
*/
    @GetMapping("/list")
    public TableDataInfo list(DetailLogs detailLogs) {
        startPage();
        List<DetailLogs> list = detailLogsService.selectDetailLogsList(detailLogs);
        return getDataTable(list);
    }

    /**
     * 导出检测详情列表
     */
    @PreAuthorize("@ss.hasPermi('archive:DetailLogs:export')")
    @Log(title = "检测详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DetailLogs detailLogs) {
        List<DetailLogs> list = detailLogsService.selectDetailLogsList(detailLogs);
        ExcelUtil<DetailLogs> util = new ExcelUtil<DetailLogs>(DetailLogs.class);
        util.exportExcel(response, list, "检测详情数据");
    }

    /**
     * 获取检测详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:DetailLogs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(detailLogsService.selectDetailLogsById(id));
    }

    /**
     * 新增检测详情
     */
    @PreAuthorize("@ss.hasPermi('archive:DetailLogs:add')")
    @Log(title = "检测详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DetailLogs detailLogs) {
        return toAjax(detailLogsService.insertDetailLogs(detailLogs));
    }

    /**
     * 修改检测详情
     */
    @PreAuthorize("@ss.hasPermi('archive:DetailLogs:edit')")
    @Log(title = "检测详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DetailLogs detailLogs) {
        return toAjax(detailLogsService.updateDetailLogs(detailLogs));
    }

    /**
     * 删除检测详情
     */
    @PreAuthorize("@ss.hasPermi('archive:DetailLogs:remove')")
    @Log(title = "检测详情", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(detailLogsService.deleteDetailLogsByIds(ids));
    }

    /**
     * 获取一个参数值
     * is_zt
     */
    @GetMapping("/iszt")
    public String iszt() {
        String isZtie = isZt + "";
        return isZtie;
    }
}
